#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename:   06-adv950-industrial.sh 
# Version:    1.0
# Date:       2020/05/15
# Author:     Lz
# Email:      lz843723683@gmail.com
# History：     
#             Version 1.0, 2020/05/15
# Function:   集成串口驱动
# Out:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

## TODO : 测试收尾清除工作
#
Adv950Clean_FTGW_INDUSTRIAL(){
	return $TPASS
}


## TODO: 调用程序退出函数
#    In: $1 => 调用脚本结果值
Adv950Exit_FTGW_INDUSTRIAL(){
        # 调用退出函数，其中调用了clean相关函数
	Exit_FTLIB ${1}
}


## TODO: 用户界面
#
Adv950USAGE_FTGW_INDUSTRIAL(){
	USAGE_FTLIB "金风工控版 - 集成串口驱动"
}


## TODO : 测试前的初始化 
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other=> TCONF
Adv950Init_FTGW_INDUSTRIAL(){
        # 调用初始化函数
	Init_FTLIB "Adv950Clean_FTGW_INDUSTRIAL"
        # 调用用户界面函数
 	Adv950USAGE_FTGW_INDUSTRIAL
}


## TODO ：强制分辨率
#
Adv950Test01_FTGW_INDUSTRIAL(){
	local flag="adv950"
	
	# 判断是否已经加载adv950
	lsmod | grep $flag
	if [ $? -eq 0 ];then
		true
	     	RetParse_FTLIB "已经加载 ${flag} 模块" "False"
		return $TPASS
	fi

	echo "modprobe adv950"
	# 加载adv950
	modprobe adv950
	if [ $? -ne 0 ];then
		# 加载失败
		false
        	RetParse_FTLIB "加载 ${flag} 模块" "False"
		return $TFAIL
	fi

	# 判断是否已经加载
	echo "lsmod | grep $flag"
	lsmod | grep $flag
	RetParse_FTLIB "已经加载 ${flag} 模块" "False"

	# 卸载adv950
	rmmod $flag
}


## TODO : Main
#  Out  : 
#         0 => TPASS
#         1 => TFAIL
#         other => TCONF
Adv950Main_FTGW_INDUSTRIAL(){
	Adv950Init_FTGW_INDUSTRIAL

	Adv950Test01_FTGW_INDUSTRIAL

	return ${TPASS}	
}

Adv950Main_FTGW_INDUSTRIAL
Adv950Exit_FTGW_INDUSTRIAL $?
